import { defHttp } from '/@/utils/http/axios';
import {
  FrontPageParams,
  StandardizePageParams,
  StdPageParams,
  StdPageResult,
  StdResponse,
} from '/@/api/model/baseModel';
import { Object, Token } from '/@/api/monitor/entity/entity';

export function listObjects(params: FrontPageParams | StdPageParams) {
  return defHttp.get<StdPageResult<Object>>({
    url: '/monitor/objects',
    params: StandardizePageParams(params),
  });
}

export function getObject(id: number) {
  return defHttp.get<Object>({
    url: `/monitor/object/${id}`,
  });
}

export function editObject(val: Object) {
  return defHttp.put<StdResponse>({
    url: `/monitor/object`,
    data: val,
  });
}

export function addObject(val: Object) {
  return defHttp.post<StdResponse>({
    url: `/monitor/object`,
    data: val,
  });
}

export function addObjectByToken(val: Token) {
  return defHttp.post<StdResponse>({
    url: `/monitor/object/token`,
    data: val,
  });
}
